<?php echo $this->validation->error_string; ?>
<?php echo form_open($this->curl .'/edit/'. $this->validation->id, 'id="create_form"')?>
<?php echo form_hidden('id', $this->validation->id)?>
<?php echo form_hidden('id_test', $id_test)?>

<table class="nostyle forma" width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
	<th colspan="2" style="width: 160px;"><?php $this->load->view('_elements/obligatory.php'); ?><?php echo $this->personality_types_model->fields['type']?></th>
	<td><div class="input_300"><?php echo form_input('type', $this->validation->type, 'class="input-text"')?></div></td>
</tr>
<tr>
	<th colspan="2"><?php echo $this->personality_types_model->fields['description']?></th>
	<td><textarea name="description" id="description"><?php echo $this->validation->description ?></textarea></td>
</tr>
<?php foreach ($traits as $i => $trait): ?>
<tr>
	<th colspan="2">
		<?php 
			echo $trait->trait; 
			$checked = ($trait->id_types_traits > 0) ? 'checked="checked"' : '';
		?>
		<input type="checkbox" name="traits_checked_ids[]" value="<?php echo $trait->id_trait; ?>" <?php echo $checked; ?> />
	</th>
	<td>
		<input type="hidden" name="traits_values[]" value="" id="value_trait_<?php echo $trait->id_trait; ?>" />
		<input type="hidden" name="traits_ids[]" value="<?php echo $trait->id_trait; ?>" />
		<div id="trait_<?php echo $trait->id_trait; ?>"></div>
	</td>
</tr>
<?php endforeach; ?>
<tr>
	<td colspan="3">&nbsp;</td>
</tr>
<tr>
	<td colspan="2"></td>
	<td>
		<input name="edit" type="submit" class="btn btn_save" id="submit" value="<?php echo T_('Submit')?>" />
		<input name="reset"  type="reset"  class="btn btn_clear" id="reset" value="<?php echo T_('Reset')?>" onclick="$('#create_form input[type=text]').val('');" />
		<input name="delete" type="button" class="btn btn_delete" id="delete" value="<?php echo T_('Delete')?>" onclick="if (confirm('<?php echo T_('Are you sure you want to delete this Type?')?>')) location='/admin/<?php echo $this->curl; ?>/delete/<?php echo $this->validation->id?>/<?php echo $id_test?>/';return false;" />		
	</td>
</tr>
</table>

<?php echo form_close()?>

<script type="text/javascript">
$(document).ready(function(){
	<?php foreach ($traits as $i => $trait): ?>
		$('#trait_<?php echo $trait->id_trait; ?>').trackbar(
			{
				onMove : function() {
					$('#value_trait_<?php echo $trait->id_trait; ?>').val(this.leftValue);
				},
				dual : false, // two intervals
				width : 300, // px
				leftLimit : <?php echo $trait->value_min; ?>, // unit of value
				leftValue : <?php if (!empty($trait->value)) echo $trait->value; else echo '0'; ?>, // unit of value
				rightLimit : <?php echo $trait->value_max; ?>, // unit of value
				rightValue : <?php if (!empty($trait->value)) echo $trait->value; else echo '0'; ?>, // unit of value
				showSmallTicks : true,
				showBigTicks : true,
				bigTicks : 9,
				hehe : ":-)"
			},
			"trait_<?php echo $trait->id_trait; ?>"
		);
	<?php endforeach; ?>
});
</script>